package factorytest.iflytek.com.einkiflytekfactorytest.myrecorder;

public class RecorderThread extends Thread {
    private RecorderOperator recorderOperator;

    public RecorderThread(String name, IRecordListener listener, String recordPath) {
        super(name);

        recorderOperator = RecorderOperator.getInstance();
        recorderOperator.setRecordingListener(listener);
        recorderOperator.setRecordPath(recordPath);
    }

    public RecorderOperator getRecorderOperator() {
        return recorderOperator;
    }

    @Override
    public void run() {
        if (recorderOperator == null) {
            return;
        }

        recorderOperator.startRecord();

    }

    public void joinThread() {

        if (recorderOperator != null) {
            recorderOperator.stopRecord();
        }

        while (isAlive()) {
            try {
                join(2500);
            } catch (InterruptedException e) {
                // Ignore.
            }
        }
    }
}
